package com.yi.suprise.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.yi.suprise.R;
import com.yi.suprise.modle.MainModle;
import com.yi.suprise.util.DensityUtil;

import java.util.ArrayList;

/**
 * Created by zhaoyi on 2016/12/9.
 */

public class MainAdapter extends RecyclerView.Adapter<MainHolder> {
    private Context mContext;
    private ArrayList<MainModle> modles;

    public MainAdapter(Context mContext, ArrayList<MainModle> modles) {
        this.mContext = mContext;
        this.modles = modles;
    }

    @Override
    public MainHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(mContext, R.layout.item_main,null);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, DensityUtil.dp2px(mContext,60));
        params.setMargins(3,3,3,0);
        view.setLayoutParams(params);
        MainHolder holder = new MainHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(MainHolder holder, int position) {
        MainModle mainModle =  modles.get(position);
        holder.tvName.setText(mainModle.getName());
        holder.tvType.setText(mainModle.getType() + "");
    }

    @Override
    public int getItemCount() {
        return modles.size();
    }
}
